package com.example.basics.simpledelay;

import org.redisson.api.RBlockingQueue;
import org.redisson.api.RDelayedQueue;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedisDelayConfig {

    private final String queueName = "queue";

    @Autowired
    RedissonClient redissonClient;

    @Bean
    public RBlockingQueue<String> rBlockingQueue() {
        return redissonClient.getBlockingQueue(queueName);
    }

    @Bean
    public RDelayedQueue<String> rDelayedQueue(@Qualifier("rBlockingQueue") RBlockingQueue<String> blockQueue) {
        return redissonClient.getDelayedQueue(blockQueue);
    }
}
